package nl.avans.osgi.persistence.dm.person.data.internal;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import nl.avans.osgi.persistence.dm.person.data.PersonService;
import nl.avans.osgi.persistence.dm.person.model.Person;

public class PersonServiceImpl implements PersonService {
    private static final String PU_NAME = "persons";
    private EntityManager em;

    public Person getEmployee(long id) {
        // TODO Auto-generated method stub
        return null;
    }

    @SuppressWarnings("unchecked")
    public List<Person> getEmployees() {
        System.out.println("PersonService: getEmployees");
        try {
            Query query = em.createQuery("Select m from EMPLOYEE m");
            return query.getResultList();
        } catch (Exception e) {
            e.printStackTrace();
            return new ArrayList<Person>();
        }
    }

    protected void activate() {
        System.out.println("PersonService activated.");
    }
    
    protected void deactivate() {
        System.out.println("PersonService deactivated.");
    }
    
}
